﻿getlist(1,0);
function getlist(pageindex, ss) {
    if (ss == 1) {
        document.getElementById("pageindex").innerHTML = "0";
        document.getElementById("pages").innerHTML = "1";
    }
    if (parseInt(document.getElementById("pageindex").innerHTML) <= parseInt(document.getElementById("pages").innerHTML) || ss == 1) {
        var json = "{";
        json += "pageindex:" + pageindex;
        try {
            var div = document.getElementById("ss");
            var input = div.getElementsByTagName("input");
            for (var i = 0; i < input.length; i++) {
                json += "," + input[i].name + ":'" + input[i].value + "'";
            }
            var select = div.getElementsByTagName("select");
            for (var i = 0; i < select.length; i++) {
                json += "," + select[i].name + ":'" + select[i].value + "'";
            }
            var radio = div.getElementsByTagName("radio");
            for (var i = 0; i < radio.length; i++) {
                json += "," + radio[i].name + ":'" + radio[i].value + "'";
            }
        }
        catch (error) {}
        json += "}";
        //重新加载列表
        $.ajax({
            url: document.getElementById("Controllers").innerHTML,
            data: encodeURI(json),
            type: "post",
            cache: false,
            timeout: 8000,
            dataType: "json",
            ContentType: "application/json; charset=utf-8",
            error: function () { console.log("请求超时"); },
            beforeSend: function () { },
            success: function (data) {
                //console.log(data);
                var html = template('tpl', data.data);
                if (data.data.pages != 0) {
                    document.getElementById("pageindex").innerHTML = data.data.pageindex + 1;
                    document.getElementById("pages").innerHTML = data.data.pages;
                    if (ss == 1)
                    { document.getElementById('tbody').innerHTML = html; }
                    else {
                        document.getElementById('tbody').innerHTML += html;
                    }
                }
                else {
                    document.getElementById('tbody').innerHTML = html;
                    //document.getElementById("nextpage").onclick = null;
                    document.getElementById("nextpage").innerHTML = "此处一片空白!";
                }
            },
        });
    }
    else {
        document.getElementById("nextpage").onclick = null;
        document.getElementById("nextpage").innerHTML = "没有更多了";
    }
}